package com.tly.common.config;

import com.tly.common.entity.SwaggerProperties;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author tly12
 */
@Configuration
public class SwaggerConfig implements WebMvcConfigurer {

    @Value("${spring.application.name}")
    private String applicationName;

    private final SwaggerProperties swaggerProperties;

    public SwaggerConfig(SwaggerProperties swaggerProperties) {
        this.swaggerProperties = swaggerProperties;
    }
    @Bean
    public OpenAPI api() {
        return new OpenAPI().info(new Info().title(applicationName+"服务")
                .description("接口调试地址"+swaggerProperties.getTryHost())
                .version("v1.0.0"));
    }
}


